package com.kefu.exam.vo;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import com.kefu.exam.model.ExamPaperAnswer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author xy
 * @date 2022/02/28
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "答题卡答案表")
public class ExamPaperAnswerInsertVo extends AbstractInsertVo<ExamPaperAnswer> {

    @NotEmpty
    @Size(max = 32)
    @ApiModelProperty(value = "关联ID")
    private String partnerId;

    @NotEmpty
    @Size(max = 32)
    @ApiModelProperty(value = "试卷")
    private String paperId;

    @NotEmpty
    @Size(max = 32)
    @ApiModelProperty(value = "答案ID")
    private String answerId;

    @NotEmpty
    @Size(max = 32)
    @ApiModelProperty(value = "试题ID")
    private String subjectId;

    @Size(max = 500)
    @ApiModelProperty(value = "答案内容")
    private String answerContent;

    @Override
    public ExamPaperAnswer convert() {
        KefuContext context = KefuContext.getKefuContext();
        ExamPaperAnswer info = new ExamPaperAnswer();
        info.setPaperId(paperId);
        info.setAnswerId(answerId);
        info.setSubjectId(subjectId);
        info.setAnswerContent(answerContent);
	    info.setCreateTime(context.getNow());
	    info.setCreateUser(context.getUserId());
        info.setCreateName(context.getUserName());
	    return info;
	}
}